package com.mr3chi.horoscopes;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class NewsHoroscope {
	private static final String DATE_FORMAT = "dd-MM-yyyy";
	private static final String SHOW_DATE_FORMAT = "MMMM, dd yyyy";
	
	private int 		id;
	private String 		horoscopeName;
	private Date 		date;
	private String 		content;
	
	public NewsHoroscope() {
		id = 0;
		horoscopeName = "";
		content = "";
		date = new Date();
	}
	
	public NewsHoroscope(String horoscopeName, Date date, String content) {
		id 					= 0;
		this.horoscopeName 	= horoscopeName;
		this.content 		= content;
		this.date 			= date;
		
	}
	
	public NewsHoroscope(int id, String horoscopeName, Date date, String content) {
		this.id 			= id;
		this.horoscopeName 	= horoscopeName;
		this.date 			= date;
		this.content 		= content;
		
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}

	public String getHoroscopeName() {
		return horoscopeName;
	}

	public void setHoroscopeName(String horoscopeName) {
		this.horoscopeName = horoscopeName;
	}
	
	public String getDateString(){
		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
		return sdf.format(date);
	}
	
	public String getShowOffString(){
		SimpleDateFormat sdf = new SimpleDateFormat(SHOW_DATE_FORMAT, Locale.US);
		return sdf.format(date);
	}
	
	public void setDateString(String date){
		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
		try {
			this.date = sdf.parse(date);
		} catch (ParseException e) {
			this.date = new Date();
		}
	}
	
	public static String getStringFromDate(Date temp){
		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
		return sdf.format(temp);
	}
}
